//
//  LGTRWZQRUrlStepCell.swift
//  KJLGT
//
//  Created by jenkin on 2019/8/24.
//  Copyright © 2019年 jenkin. All rights reserved.
//

import UIKit

class LGTRWZQRStepCell: UITableViewCell {

    var bottomClickBlock:ClickIndexBlock?
    var qrImage:UIImageView?
    var titleLabel:UILabel?
    var stepLabel:UILabel?
    var bottomView:LGTRWZStepCellBottomView?
    var stepCellClickBlock:ClickStepPathBlock?
    
    private var _model:Dictionary<String, Any>?
    var path:IndexPath?
    var model:Dictionary<String, Any>{
        get{
            return _model ?? Dictionary.init()
        }set{
            _model = newValue
            self.setData()
        }
    }
    
    func setData(){
        
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        // Configure the view for the selected state
    }

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = UITableViewCell.SelectionStyle.none
        self.titleLabel = LGTViewCreateUtil.share.createLabel(textAlignment: NSTextAlignment.left, textColor: TextColor, fontSize: SizeFitFloat(15), text: "扫描下方二维码")
        self.titleLabel?.numberOfLines = 0
        self.addSubview(self.titleLabel!)
        self.titleLabel!.snp.makeConstraints { (make) in
            make.left.equalTo(SizeFitFloat(41))
            make.right.equalTo(-SizeFitFloat(48))
            make.top.equalTo(SizeFit(22))
        }
        
        self.stepLabel =  LGTViewCreateUtil.share.createLabel(textAlignment: NSTextAlignment.center, textColor: UIColor.white, fontSize: SizeFitFloat(16), text: "1", corner: SizeFitFloat(10))
        self.addSubview(self.stepLabel!)
        self.stepLabel?.backgroundColor = YellowColor
        self.stepLabel!.snp.makeConstraints { (make) in
            make.left.equalTo(SizeFit(13))
            make.height.width.height.equalTo(SizeFit(20))
            make.centerY.equalTo(self.titleLabel!)
        }
        
        self.qrImage = LGTViewCreateUtil.share.createImageViewCorner(corner: SizeFitFloat(5))
        self.addSubview(self.qrImage!)
        self.qrImage!.snp.makeConstraints { (make) in
            make.left.equalTo(SizeFitFloat(49))
            make.width.height.equalTo(SizeFit(100))
            make.top.equalTo(SizeFit(53))
        }
        
        self.bottomView = LGTRWZStepCellBottomView()
        self.addSubview(self.bottomView!)
        self.bottomView?.snp.makeConstraints({ (make) in
            make.left.right.bottom.equalTo(0)
            make.top.equalTo(self.qrImage!.snp_bottomMargin)
            make.height.equalTo(SizeFit(36))
        })
        
        weak var weakSelf = self
        self.bottomClickBlock = { (index:Int) in
            weakSelf?.gotoActionBlock(index: index)
        }
        self.bottomView?.clickIndex = self.bottomClickBlock
    }
    
    func gotoActionBlock(index:Int){
        if self.stepCellClickBlock != nil{
            self.stepCellClickBlock!(self.model, self.path!, index, nil)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
